package com.project.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.LinkBean;
import com.project.mapper.ILinkMapper;
import com.project.service.ILinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author lyl
 * description:
 */
@Service
@Transactional
public class LinkServiceImpl implements ILinkService {
    @Autowired
    private ILinkMapper iLinkMapper;

    @Override
    public void add(LinkBean linkBean) {
        iLinkMapper.add(linkBean);
    }

    @Override
    public void del(int linkId) {
        iLinkMapper.del(linkId);
    }

    @Override
    public void updateTel(int linkId, String newTel) {
        iLinkMapper.updateTel(linkId, newTel);
    }

    @Override
    public LinkBean findById(int linkId) {
        return iLinkMapper.findById(linkId);
    }

    @Override
    public PageInfo<LinkBean> findAllByPage(int pageNo) {
        PageHelper.startPage(pageNo, 3);
        PageInfo<LinkBean> info = PageInfo.of(iLinkMapper.findAllByPage());
        return info;
    }
}
